<script language="javascript">
var btnYes = "Yes";
var btnNo = "No";
var btnOk = "Ok";
var btnCancel = "Cancel";
var btnDrop = "Drop filter";
var btnApply = "Apply filter";
</script>
<script language="javascript" src="/scripts/json.js"></script>
<script language="javascript" src="/scripts/tasks.js"></script>
<style>
.task-list {white-space: nowrap; text-align: center; border-bottom: 1px dotted; width: auto; }
.task-list-hover {background: #ffdd57 url(/[{$theme}]/images/ui-bg_gloss-wave_70_ffdd57_500x100.png) 50% 50% repeat-x;}
</style>
<h3 class="ui-widget-header-h3">Tasks</h3>
<div style="margin: 20;">
<div style="width: 100%; text-align: left;"><button id="btn_top" onclick="RefreshList();">Refresh</button>
<button id="task_filter"onclick="taskFilter();">Filter the list</button>
<button id="task_add" onclick="addTask();">Add new task</button>
</div>
[{if $TaskNum > 0}]
	<table width="100%" id='userstable'>
		<tr class="ui-widget-header">
			<th style="width: auto;">Profile</th>
			<th style="width: auto;">Name</th>
			<th style="width: 5%;">Status</th>
			<th style="width: 5%;">Completion</th>
			<th style="width: auto;">Start Time</th>
			<th style="width: auto;">Finish Time</th>
			<th style="width: auto;">Last Activity</th>
			<th style="width: auto;">Actions</th>
		</tr>
[{section name=task loop=$TaskList}]<tr class="task-list" onmouseover="$(this).addClass('task-list-hover'); return true;" onmouseout="$(this).removeClass('task-list-hover'); return true;" >
			<td class="task-list">[{$TaskList[task][1]}]</td>
			<td class="task-list">[{$TaskList[task][2]}]&nbsp;</td>
			<td class="task-list" style="width: 5%;">
			[{assign var=st_ico value='ui-icon-help'}]
			[{if $TaskList[task][3] == 0}]
			[{assign var=st_ico value='ui-icon-eject'}]
			[{/if}]
			[{if $TaskList[task][3] == 1}]
			[{assign var=st_ico value='ui-icon-play'}]
			[{/if}]
			[{if $TaskList[task][3] == 2}]
			[{assign var=st_ico value='ui-icon-pause'}]
			[{/if}]
			[{if $TaskList[task][3] == 3}]
			[{assign var=st_ico value='ui-icon-circle-check'}]
			[{/if}]
			[{if $TaskList[task][3] == 4}]
			[{assign var=st_ico value='ui-icon-stop'}]
			[{/if}]
			[{if $TaskList[task][3] == 5}]
			[{assign var=st_ico value='ui-icon-alert'}]
			[{/if}]
			<span class="ui-icon [{$st_ico}] ui-icon-btn" title="[{$TaskList[task][8]}]"></span>
			[{$TaskList[task][8]}]</td>
			<td class="task-list" style="width: 5%;">[{$TaskList[task][4]}]%</td>
			<td class="task-list">[{$TaskList[task][5]}]</td>
			<td class="task-list">[{$TaskList[task][6]}]</td>
			<td class="task-list">[{$TaskList[task][7]}]</td>
			<td class="task-list">
				<a href="#" onclick="return showInfo('[{$TaskList[task][0]}]');">
					<span class="ui-icon ui-icon-document ui-icon-btn" title="Task Details"></span></a>
[{if $TaskACL == 1}]
	[{if $TaskList[task][3] != 3 && $TaskList[task][3] != 4}]
				<a href="#" onclick="return stopTask('[{$TaskList[task][0]}]');">
					<span class="ui-icon ui-icon-power ui-icon-btn" title="Stop Task"></span></a>
	[{/if}]
	[{if $TaskList[task][3] == 1}]
				<a href="#" onclick="return pauseTask('[{$TaskList[task][0]}]');">
					<span class="ui-icon ui-icon-pause ui-icon-btn" title="Pause Task"></span></a>
	[{/if}]
	[{if $TaskList[task][3] == 2}]
				<a href="#" onclick="return resumeTask('[{$TaskList[task][0]}]');">
					<span class="ui-icon ui-icon-play ui-icon-btn" title="Resume Task"></span></a>
	[{/if}]
	[{if $TaskList[task][3] != 1 && $TaskList[task][3] != 2 && $TaskList[task][3] != 5}]
				<a href="#" onclick="return deleteTask('[{$TaskList[task][0]}]');">
					<span class="ui-icon ui-icon-closethick ui-icon-btn" title="Delete Task"></span></a>
	[{/if}]
[{/if}]
                </td>
		</tr>
            [{/section}]
	</table>
[{else}]
	<div class="ui-state-error ui-corner-all" width="100%" style="padding: 5px;">
		<span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert"></span>
		No tasks found!
	</div>
[{/if}]
<div style="width: 100%; text-align: left;"><button id="btn_bottom" onclick="RefreshList();">Refresh</button></div>
</div>
<div id="confirm_delete" title="Confirmation" style="display: none">
    <table><tr>
        <td><img src="/[{$theme}]/images/warning.png"> </td><td>Are you shure to delete task?</br>
		This operation can't be undone!</td>
    </tr></table>
</div>
<div id="confirm_stop" title="Confirmation" style="display: none">
    <table><tr>
        <td><img src="/[{$theme}]/images/warning.png"> </td><td>Are you shure to stop task?<br/>
		Task can't be resumed after stop operation!</td>
    </tr></table>
</div>
<div id="task_notify" title="Error!" style="display: none"><span id="task_notify_text"></span></div>
<div id="task_filter_edit" title="Task list filter" style="display: none">
<form id="filter_form" action="#" onsubmit="return false;"><input type="hidden" name="use_filter" value="0"/>
<table width="100%">
<tr><td><input type="checkbox" name="use_profile" /></td><td width="100%">Profile</td>
	<td><select name="op_profile"><option value="eq" selected>==</option><option value="ne">&lt;&gt;</option></select>
	</td><td><input type="text" name="val_profile" /></td><td><select name="sort_profile"><option value="no">no sort</option><option value="asc">ascending</option><option value="desc">descending</option></select></td></tr>
<tr><td><input type="checkbox" name="use_name" /></td><td width="100%">Name</td>
	<td><select name="op_name"><option value="eq" selected>==</option><option value="ne">like</option></select>
	</td><td><input type="text" name="val_name" /></td><td><select name="sort_name"><option value="no">no sort</option><option value="asc">ascending</option><option value="desc">descending</option></select></td></tr>
<tr><td><input type="checkbox" name="use_status" /></td><td width="100%">Status</td>
	<td><select name="op_status"><option value="eq" selected>==</option><option value="ne">&lt;&gt;</option></select>
	</td><td><input type="text" name="val_status" /></td><td><select name="sort_status"><option value="no">no sort</option><option value="asc">ascending</option><option value="desc">descending</option></select></td></tr>
<tr><td><input type="checkbox" name="use_complete" /></td><td width="100%">Completion</td>
	<td><select name="op_complete"><option value="eq" selected>==</option><option value="ne">&lt;&gt;</option><option value="lt">&lt;</option><option value="le">&lt;=</option><option value="gt">&gt;</option><option value="ge">&gt;=</option></select>
	</td><td><input type="text" name="val_complete" /></td><td><select name="sort_complete"><option value="no">no sort</option><option value="asc">ascending</option><option value="desc">descending</option></select></td></tr>
<tr><td><input type="checkbox" name="use_starttm" /></td><td width="100%">Start Time</td>
	<td><select name="op_starttm"><option value="eq" selected>==</option><option value="ne">&lt;&gt;</option><option value="lt">&lt;</option><option value="le">&lt;=</option><option value="gt">&gt;</option><option value="ge">&gt;=</option></select>
	</td><td><input type="text" name="val_starttm" /></td><td><select name="sort_starttm"><option value="no">no sort</option><option value="asc">ascending</option><option value="desc">descending</option></select></td></tr>
<tr><td><input type="checkbox" name="use_finishtm" /></td><td width="100%">Finish Time</td>
	<td><select name="op_finishtm"><option value="eq" selected>==</option><option value="ne">&lt;&gt;</option><option value="lt">&lt;</option><option value="le">&lt;=</option><option value="gt">&gt;</option><option value="ge">&gt;=</option></select>
	</td><td><input type="text" name="val_finishtm" /></td><td><select name="sort_finishtm"><option value="no">no sort</option><option value="asc">ascending</option><option value="desc">descending</option></select></td></tr>
<tr><td><input type="checkbox" name="use_pingtm" /></td><td width="100%">Last Activity</td>
	<td><select name="op_pingtm"><option value="eq" selected>==</option><option value="ne">&lt;&gt;</option><option value="lt">&lt;</option><option value="le">&lt;=</option><option value="gt">&gt;</option><option value="ge">&gt;=</option></select>
	</td><td><input type="text" name="val_pingtm" /></td><td><select name="sort_pingtm"><option value="no">no sort</option><option value="asc">ascending</option><option value="desc">descending</option></select></td></tr>
</table></form>
</div>
<script language="javascript">
var use_filter="0";
getFilter();
setFilterBtn();
$('#btn_top').button({icons: {primary: 'ui-icon-refresh'}});
$('#btn_bottom').button({icons: {primary: 'ui-icon-refresh'}});
$('#task_filter').button({icons: {primary: 'ui-icon-search'}});
$('#task_add').button({icons: {primary: 'ui-icon-circle-plus'}});
</script>